"""
变量名 xjz_ksf  值：码子 (多个换行)
变量名 xjz_Api  值：过检APi 例：192.168.100.1:5000
利润：懂得就玩,不懂就无视 (亏钱与作者无关)
"""

"""
Create at [2025-03-27 19:14:56]
"""
import requests
import os
import sys
import platform
import subprocess
import importlib
import datetime
from urllib.parse import urlparse
import logging
import socket

logging.basicConfig(level=logging.INFO, format="[%(levelname)s] ===> %(message)s")
log = logging.getLogger(__name__)

THIS_Proxies = "https://github.huaji.asia/"  # 网络不行就填Github代理 这里只给出一个要是不行就自己找 https://github.huaji.asia/

data = "7NTyh4JkIgYD9O8LedD/WnDG5WolmuEaFKoaOf7sPu/y5eVfxP821KZAP/vhr6MVyQxNtCnyG5mVBggAjHW8+y5mpQWEjluzt90N4+zwIbdIHhbRsWOy9L55KkBJlDJTx5ZGnkoarHSOKRyCBYwOMVqK0bKAOmzFfe0EGW2ZAYTxj89u6Z1Kyc89e6STBiG70HDHGIYb40ZWXfXqGjQqupsGxpuwnIq6fabbVaWROjUaIjO2ui1/ik+fAJFsOXlVGAHZzYwXqLvoajVeOMhRlrsECzqnpkLSWf7g4om9pxCNLdjuf9AR091lfNhmOUuJFEVjU9XyQtHVSrtJP89TMcUjTeYZQuxUU0UD+gsMihixhFkLJQWqlzc1p15gsUd7d8aK7Fi69v0tBp7ksLrkmvVVtslI7pJEpgBBTaf1HD/5qz/ZScDG9VrvOjEKDXZFEqu9xfw3CQaIgxK6DrdKepq7yspWRQdjnfoO5TZeDOvshaoySdnSabJGCUY3laujctJZdHKXUCquuTiYujo+nOhTCH4aAHigz7f65iqMyFgfoHqKDEUVGl5NWAYFMVjG1FET2OHRmdJSwfVYywaFKToB5cM3OAhi/YZCLDSunCS7N5VP1awpsTux4ZWBTv08SV42txI791RRwp4ycyk4dac9J73m7+DJSR9ICTRMuxxClkmozVUFZap9/Eu6qFtuqdjwShklHdwJ7usDdhTTUZ8aetYWVVPamTWt9sIhx0sn/CY7F79qYorg7dlaK42Mh6vELV88c6FF/6/0Va1atMUml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h5bMYp1GUH/7USGokKtolEII0Ozi1t9jD/WWifgZ5ZyFbuRM1YjAhbOV/qtgd6LyP93TjmpfevecGUCMqxVUmFEBIL0Hzp5bxjC/qiNrfMeu16eVhCwGUncg3dI28kogsJuMXqBNqoORtwlUYwYVx45vid+DOkoN/8wt+xF9FiQ4hafpamOqo0cAnj8KWTEQYtyla+zjsBw81nF+tjg5Kv9aL0aQUkZB547vCIW+M4GFVtvWZWXn7EijH8ycxhu4EjTw15CDuSIbIlJo/8tQkXzmYjwWMZxgZPbc6y/hGwlkyupX02F1Bqv2V1t2hnOtmRvRIcnvXuL9MOF2DDsu2N/6XCBZaXBwDaiaxpj/gu2ac1WK9rDbRJ8BXO1Y3gTqVN9KJztMRu76PYb9Jtt3VcchCTNw8fMt8uoqrW0H9xXfkcjNnRRoIdr8YUeynfdmPZZfwtY70IuV99nJ9vKAdr7QCu7EOMlXhfO83rlmvLhmDwcve0PdVHt"
func = "main"

GithubUrl = (
    f"{THIS_Proxies.rstrip('/')}/https://raw.githubusercontent.com/huaji8/So_common/master/so"
    if THIS_Proxies
    else "https://raw.githubusercontent.com/huaji8/So_common/master/so"
)
THIS_MODE = "Huaji_SoLoader"
So_name = f"{THIS_MODE}.so"


def get_system_info() -> None:
    global Download_name
    python_version = (
        f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
    )
    download_pyver = f"{sys.version_info.major}.{sys.version_info.minor}"
    processor_arch = (
        platform.machine().replace("AMD64", "x86_64").replace("x64", "x86_64")
    )
    system_name = platform.system()
    system_ver = platform.release() + " " + platform.version()
    system_arch = platform.architecture()[0]
    if system_name == "Darwin":
        system_name = "macOS"
        system_ver = platform.mac_ver()[0]
    elif system_name == "Windows":
        system_ver = f"{platform.release()} (Build {platform.win32_ver()[1]})"

    log.info(
        f"系统信息 [Python/{python_version}] [系统架构 {processor_arch}] [{system_name}/{system_ver} {system_arch}]"
    )
    if download_pyver not in ["3.10", "3.11", "3.12"]:
        log.error(
            f"当前Python版本不支持运行此脚本，请使用Python3.10或3.11或3.12运行此脚本,什么??你不重装,简单,删除本脚本然后睡觉觉就行了.."
        )

    if processor_arch == "x86_64" and system_name == "Linux":
        Download_name = f"{THIS_MODE}_{download_pyver}_x64.so"
    elif processor_arch == "aarch64" and system_name == "Linux":
        Download_name = f"{THIS_MODE}_{download_pyver}_aarch64.so"
    else:
        Download_name = f"{THIS_MODE}_{download_pyver}_x64.so"

    if processor_arch not in ["x86_64", "aarch64"]:
        log.warning(f"当前系统架构大概率不支持运行此脚本...")
        return
    elif "Linux" not in system_name:
        log.error(f"当前系统不支持运行此脚本，请使用Linux运行此脚本")
    else:
        log.info("系统检测通过,开始运行脚本")
        return

    exit()


def download_file(save_path: str = None) -> bool:
    url = GithubUrl + "/" + Download_name

    try:
        try:
            socket.create_connection(("www.github.com", 80), timeout=5)
            socket.create_connection(("www.github.com", 443), timeout=5)
        except (socket.timeout, socket.gaierror):
            log.warning("无法连接到Github,大概率下载是失败的,请检查网络或使用代理")

        if not save_path:
            file_name = os.path.basename(urlparse(url).path) or "downloaded_file"
            save_path = os.path.join(os.getcwd(), file_name)
        if os.path.exists(save_path) and os.path.getsize(save_path) == 0:
            os.remove(save_path)
        save_dir = os.path.dirname(save_path)
        os.makedirs(save_dir, exist_ok=True)
        curl_cmd = "curl.exe" if platform.system() == "Windows" else "curl"
        cmd = [
            curl_cmd,
            "-L",
            "-f",
            "--silent",
            "--show-error",
            "-o",
            save_path,
            "-m",
            "180",
            url,
        ]

        result = subprocess.run(
            cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
        )

        if not os.path.exists(save_path):
            log.error(f"下载文件不存在: {save_path}")
            return False
        if os.path.getsize(save_path) == 0:
            os.remove(save_path)
            log.error(f"下载文件为空: {save_path}")
            return False
        if result.returncode != 0:
            log.error(f"下载失败: {result.stderr.strip()}")
            return False
        log.info(f"文件下载成功: {save_path}")
        os.rename(Download_name, So_name)
        return True

    except subprocess.CalledProcessError as e:
        error_msg = f"下载失败: {e.stderr.strip()}" if e.stderr else "未知curl错误"
        log.error(error_msg)
        return False
    except Exception as e:
        log.error(f"下载异常: {str(e)}")
        return False


def dynamic_import(module_name: str) -> object:
    return importlib.import_module(module_name)


def Run() -> None:
    if os.path.exists(So_name):
        log.info("so文件存在,开始运行")
        print("=" * 30)
        obj = dynamic_import(THIS_MODE)
        obj.run(func, data)
    else:
        log.info("so文件不存在,开始下载")
        if download_file():
            Run()
        else:
            log.error("下载失败,请检查网络或使用代理")


if __name__ == "__main__":
    get_system_info()
    Run()
